
<section id="content">

    <div class="page page-fullwidth-layout">

        <div class="pageheader">

            <div class="page-bar">

                <ul class="page-breadcrumb">
                    <li>
                        <a href="{:url('/admin')}"><i class="fa fa-home"></i> 起始页</a>
                    </li>
                    <li>
                        <a href="{:url($data.module_url)}">{$data.module_name}列表</a>
                    </li>
                </ul>

            </div>

        </div>

        <!-- page content -->
        <div class="pagecontent">

            <!-- row -->
            <div class="row">
                <!-- col -->
                <div class="col-md-12">
                    <!-- tile -->
                    <section class="tile">
                        <form action="{:url($data.module_url)}" style="padding-top: 10px;" class="navbar-form form-inline" method="post">
                            <div class="form-group">
                                <label class="control-label" for="input-mobile">手机号码</label>
                                <div class="input-group">
                                    <input type="text" name="mobile" value="" placeholder="手机号码" id="input-mobile" class="form-control">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label">微信昵称</label>
                                <div class="input-group">
                                    <input type="text" name="c_nickname" value="" placeholder="微信昵称"  id="input-c_nickname" class="form-control">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label">时间范围</label>
                                <div class="input-group">
                                    <input type="text" name="startTime" class="Wdate" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',readOnly:true})"  style="width:150px;padding: 16px;border: 1px solid #dbe0e2;" />至
                                    <input type="text" name="endTime" class="Wdate" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',readOnly:true})"  style="width:150px;padding: 16px;border: 1px solid #dbe0e2;" />
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label">客戶状态</label>
                                <select name='customer_type' class="form-control">
                                    <option value='0'>全部</option>
                                    <option value='1'>新增</option>
                                    <option value='2'>潛在</option>
                                    <option value='3'>意向</option>
                                    <option value='4'>准客戶</option>
                                    <option value='5'>合作</option>
                                    <option value='6'>已认证</option>
                                    <option value='7'>已放弃</option>
                                </select>
                            </div>
                            <div class="form-group">
                                {if($is_admin == 1)}
                                <select name="group_select" class="form-control">
                                    <option value="0">选择部门</option>
                                    {if($groups)}
                                    {foreach $groups as $key=>$v)}
                                    <option value="{$v['id']}">{$v['group_name']}</option>
                                    {/foreach}
                                    {/if}
                                </select>
                                {/if}
                                <select name="user_select" class="form-control">
                                    <option value="0">选择员工</option>
                                    {if($users)}
                                    {foreach $users as $key=>$v)}
                                    <option value="{$v['id']}">{$v['nickname']}</option>
                                    {/foreach}
                                    {/if}
                                </select>
                                <!--<button class="btn btn-primary sub_permission">查询</button>-->
                            </div>
                            <!--<div class="form-group">
                                <label class="control-label">所属用户</label>
                                <select name='user_id' class="form-control">
                                    <option value='0'>选择</option>
                                    {volist name='users' id='val'}
                                    <option value='{$val.id}'>{$val.nickname}</option>
                                    {/volist}

                                </select>
                            </div>-->

                            <div class="form-group">
                                <button type="submit" class="btn btn-primary pull-right"><i class="fa fa-search"></i> 查詢</button>
                            </div>
                        </form>

                        <div class="tile-body">
                           <div class="alert alert-info" style="display:none;">显示一些提示信息</div>

                            <div class="table-responsive">
                                <table class="table table-striped table-hover table-custom" id="products-list">
                                    <thead>
                                        <tr>
                                            <th>用户ID</th>
                                            <th>用户名</th>
                                            <th>微信昵称</th>
                                            <th>微信头像</th>
                                            <th>手机号</th>
                                            <th>性别</th>
                                            <th>会员等级</th>
                                            <th>客户状态</th>
                                            <th>添加时间</th>
                                            <th>所属用户</th>
                                            <th>操作</th>
                                        </tr>
                                    </thead>
                                    <tbody>

                                        {foreach $list as $item}
                                        <tr id="tr_{$item['customers_id']}">
                                            <td class="id">{$item['customers_id']}</td>
                                            <td class="name">{$item['name']}</td>
                                            <td class="c_nickname">{$item['c_nickname']}</td>
                                            <td class="header_pic">
                                                <img src="{:gethead_pic($item['mobile'])}" width="40" height="40" style="border-radius: 50%;">
                                            </td>
                                            <td class="mobile">{$item['mobile']}</td>
                                            <td>
                                                {if condition="$item['sex'] eq 1"}男{elseif condition="$item['sex'] eq 2"}女{/if}
                                            </td>
                                            <td>
                                                {if condition="$item['customer_levlel'] eq 1"}
                                                    铜牌
                                                {elseif condition="$item['customer_levlel'] eq 2"}
                                                    银牌
                                                {elseif condition="$item['customer_levlel'] eq 3"}
                                                    金牌
                                                {elseif condition="$item['customer_levlel'] eq 4"}
                                                    钻石
                                                {/if}
                                            </td>
                                            <td  style="vertical-align: middle;  position: relative;top: 10px;"
                                                 {if condition="$item['customer_type'] eq 1"}
                                            <span class="btn">新增客户</span>
                                            {elseif condition="$item['customer_type'] eq 2"}
                                            <span class="btn btn-info">潜在客户</span>
                                            {elseif condition="$item['customer_type'] eq 3"}
                                            <span class="btn btn-success">意向客户</span>
                                            {elseif condition="$item['customer_type'] eq 4"}
                                            <span class="btn btn-warning">准客户</span>
                                            {elseif condition="$item['customer_type'] eq 5"}
                                            <span class="btn btn-primary"">合作客户</span>
                                            {elseif condition="$item['customer_type'] eq 6"}
                                            <span class="btn btn-inverse">已认证</span>
                                            {else/}
                                            <span class="btn btn-danger">已放弃</span>
                                            {/if}
                                            </td>
                                            <td>{$item['addtime']|date='Y-m-d H:i',###}</td>
                                            <td>{$item['nickname']}</td>
                                            <td>
                                                <a class="btn btn-info owngoods" href="{:url('admin/customers/owngoods',['mobile'=>$item['mobile']])}">
                                                    <i class="glyphicon glyphicon-user icon-white" ></i>
                                                    ta的拍品
                                                </a>
                                                <a class="btn btn-info" id="followLog" href="{:url($data.module_url.'followloglist',['customers_id'=>$item['customers_id']])}">
                                                    <i class="glyphicon glyphicon-list-alt icon-white" ></i>
                                                    跟进记录
                                                </a>
                                                <a class="btn btn-info" href="{:url($data.module_url.'read',['customers_id'=>$item['customers_id']])}">
                                                    <i class="glyphicon glyphicon-edit icon-white"></i>
                                                    编辑
                                                </a>
                                                <a class="btn btn-danger" href="javascript:;"  onclick="if(confirm('确定要删除该客户吗')){ deleteData({$item['customers_id']})}">
                                                    <i class="glyphicon glyphicon-trash icon-white"></i>
                                                    删除
                                                </a>
                                            </td>

                                        </tr>
                                        {/foreach}
                                    </tbody>
                                </table>
                            </div>
                            <div class="text-center">{$list->render()}</div>
                        </div>
                        <!-- /tile body -->

                    </section>
                    <!-- /tile -->

                </div>
                <!-- /col -->
            </div>
            <!-- /row -->

        </div>
        <!-- /page content -->
        <script type="text/javascript">

            function deleteData(customers_id){
                $.ajax({
                    type:"get",
                    data: {'customers_id':customers_id},
                    url:"{:url($data.module_url.'delete')}",
                    success:function(data){
                        if(data.error == 0){
                            $('#tr_'+data.customers_id).remove();
                        }
                        $('.alert').html(data.msg).show();
                        setTimeout(function() {
                            $('.alert').hide();
                        }, 3000);
                    },
                    error:function(data){

                    }
                });
            }
            function checkform(){
                var follow_time = document.getElementById("follow_time").value;
                var remark = document.getElementById("remark").value;
                if(!follow_time){
                    alert("跟进时间不能为空");
                    return false;
                }
                if(!remark){
                    alert("备注不能为空");
                    return false;
                }
                document.getElementById("myform").submit();
            }

            $(function() {

                //选择部门触发选择会员
                $('select[name = group_select]').change(function(){
                    $('select[name=user_select ]').html('');
                    var group_id = $(this).val();
                    if(group_id > 0) {
                        $.ajax({
                            type:"POST",
                            url:"{:url('/admin/Chart/getUsersByGroupId')}",
                            data: {group_id:group_id},
                            dataType: 'json',
                            success:function(res){
                                if(res.code == 200){
                                    if(res.data.length > 0){
                                        var i;
                                        var str = '<option value="0">选择员工</option>';
                                        for(i=0;i<res.data.length;i++){
                                            str += '<option value="'+res.data[i].id+'">'+res.data[i].nickname+'</option>';
                                        }
                                         //alert(str);
                                        $('select[name=user_select ]').html(str);
                                    }else{
                                        $('select[name=user_select ]').html('<option value="0">选择员工</option>');
                                    }
                                }
                            }
                        });
                    }
                })

                //选择角色获取角色权限
                $('select[name = user_select]').change(function(){
                    var group_id = $('select[name=group_select]').val();
                    var user_id  = $(this).val();

                })



            })
        </script>

    </div>

</section>
<!--/ CONTENT -->
